<?php
/**
 * @author yupoxiong<i@yufuping.com>
 * @title 首页
 */

namespace app\api\controller;
use app\common\model\User;
use app\common\model\SysConfig;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\Request;
use app\common\service\ShopService;
class IndexController extends Controller
{

    protected $shopService;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->shopService = new ShopService();
    }

    protected $authExcept = [
        'home','data_submit'
    ];

    /**
     * @throws DbException
     * @throws ModelNotFoundException
     * @throws DataNotFoundException
     */
    public function home(Request $request)
    {
        //首页banner
        $index_banner = get_ad('index_banner',1);
        // 首页弹窗图片
        $index_popup = get_ad('index_popup',1);
        //热门商品
        $hot_goods = $this->shopService->getHotGoods();
        $data = [
            'index_banner' =>$index_banner,
            'index_popup' =>$index_popup,
            'hot_goods' => $hot_goods
        ];
        return success($data);
    }


}